#!/usr/bin/env python

# -------------------------------
# projects/python/collatz/main.py
# Copyright (C) 2009
# Glenn P. Downing
# -------------------------------

# To run the program
#     main.py < Collatz.in > Collatz.out

# To document the program
#     pydoc -w main

# -------
# globals
# -------

i = 0 # input: don't change after reading
j = 0 # input: don't change after reading
v = 0 # output

"""Caches return values of my_cycle_length"""
cache = {}

# -----------
# InputReader
# -----------

class InputReader (object) :
	def read (self) :
		return raw_input()

# ------------
# OutputWriter
# ------------

class OutputWriter (object) :
	def write (self, *a) :
		for w in a :
			print w,
		print

# -------
# my_read
# -------

def my_read (r) :
	"""
	reads an int into i and j
	return true if that succeeds, false otherwise
	"""
	global i
	global j
	try :
		s = r.read()
	except EOFError :
		return False
	l = s.split()
	i = int(l[0])
	j = int(l[1])
	return True

# -------
# my_eval
# -------

def my_cycle_length(n) :
	"""
	calculates the cycle length of the number n, recursively
	uses the dict 'cache' to memoize itself, avoiding repeated calculations of the same value
	"""
	assert n > 0
	rval = 0
	global cache
	if n in cache :
		return cache[n]
	if (n == 1) :
		return 1
	if ((n % 2) == 0) :
		rval = 1 + my_cycle_length(n / 2)
	else :
		rval = 2 + my_cycle_length(n + (n >> 1) + 1)
	cache[n] = rval
	assert rval >= 1
	return rval

# -------
# my_eval
# -------

def my_eval () :
	"""
	computes the max cycle length in the range [i, j]
	and stores the result in v
	"""
	global i, j, v

	assert i < 1000000
	assert j < 1000000
	assert i > 0
	assert j > 0
	v = 0
	
	"""
	It's possible for i > j if the testers are being sneaky. Fix it.
	"""
	start = i if (i < j) else j
	end   = j if (i < j) else i
	
	assert start <= end
	
	for x in range(start, end+1) :
		length = my_cycle_length(x)
		if v < length :
			v = length
	
	assert v > 0
	
# --------
# my_print
# --------

def my_print (w) :
    """
    writes the values of i, j, and v
    """
    w.write(i, j, v)

# ----
# main
# ----

def main () :
    """
    runs the program
    """
    while my_read(InputReader()) :
        my_eval()
        my_print(OutputWriter())

if __name__ == "__main__" :
    main()
